package com.tutorial;

import java.io.IOException;

import com.db.DataBaseHelper;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

public class LocationDemo extends Activity implements OnClickListener {
	public DataBaseHelper db;

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.app.Activity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		
		 db = new DataBaseHelper(this);
		 try {
				db.createDataBase();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		
		View viewButton = findViewById(R.id.view_button);
		viewButton.setOnClickListener(this);
		View shareButton = findViewById(R.id.share_button);
		shareButton.setOnClickListener(this);
		View aboutButton = findViewById(R.id.about_button);
		aboutButton.setOnClickListener(this);
		View exitButton = findViewById(R.id.exit_button);
		exitButton.setOnClickListener(this);
		db.close();
		
	}

	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.view_button:
			Intent view = new Intent(this, LocationList.class);
			startActivity(view);
			break;
		case R.id.share_button:
			Intent share = new Intent(this, Share.class);
			startActivity(share);
			break;
		case R.id.about_button:
			Intent about = new Intent(this, About.class);
			startActivity(about);
			break;
		case R.id.exit_button:
			finish();
			break;

		}
	}
	
}
